﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Workflow.ComponentModel;
using System.Diagnostics;

namespace ExternalActivities
{
    public class AccumulatorActivity : Activity
    {
        public AccumulatorActivity()
        {
        }

        public AccumulatorActivity( string name ) : base( name )
        {
        }

        public static readonly DependencyProperty InputProperty = DependencyProperty.Register( "Input", typeof( decimal ), typeof( AccumulatorActivity ) );

        public decimal Input
        {
            get { return (decimal) GetValue( InputProperty ); }
            set { SetValue( InputProperty, value ); }
        }

        protected override ActivityExecutionStatus Execute( ActivityExecutionContext aec )
        {
            SomeTransactionalService svc = aec.GetService<SomeTransactionalService>();

            Debug.Assert( svc != null );

            svc.Add( Input );

            return ActivityExecutionStatus.Closed;
        }
    }
}
